package com.buding.fx.base.juc.smp;

import java.util.concurrent.Semaphore;

public class PayThread implements Runnable{
    Semaphore semaphore;

    String orderId;

    public PayThread(Semaphore semaphore,String orderId) {
        this.semaphore = semaphore;
        this.orderId = orderId;
    }

    @Override
    public void run() {
        try{
            semaphore.acquire();
            System.out.println(orderId+" 获取信号量");
            Thread.sleep(2000);
        }catch (Exception e){

        }finally {
            semaphore.release();
        }
    }
}
